package com.ruoyi.web.config;

import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;

import java.io.IOException;

/**
 * 日志发送到前端
 *
 * @author Hack2003
 * @date 2024/3/25 15:38
 **/
@Component
public class LogWebSocketHandler extends TextWebSocketHandler {
    @Override
    protected void handleTextMessage(WebSocketSession session, TextMessage message) {
        // 在这里处理日志信息并发送到前端
        try {
            session.sendMessage(new TextMessage("Log message: " + message.getPayload()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}